Skip to content

feat: support whole-value Variant scan pushdown - #6443

Open
peterxcli wants to merge 6 commits into
apache:mainfrom
peterxcli:feat/variant-whole-value-pushdown
Open

peterxcli wants to merge 6 commits into
apache:mainfrom
peterxcli:feat/variant-whole-value-pushdown

Conversation

@peterxcli

@peterxcli peterxcli commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Which issue does this PR close?

Closes #5519.

Rationale for this change

#5868 already supports native SELECT v FROM t scans with spark.sql.variant.pushVariantIntoScan=false. Spark 4.1 enables this rewrite by default, requesting struct<0: variant> instead of a plain Variant column, which previously forced Comet to fall back. This PR accepts that whole-value request and reuses the existing Variant reader.

What changes are included in this PR?

Recognize Spark's single full-Variant request, reuse the native normalizer, and preserve the wrapper's metadata and nulls through serialization and FFI. Update the Variant support documentation.

How are these changes tested?

Native Parquet and Comet Variant tests cover canonical and shredded values, nulls, metadata, unsupported requests, and reader guards. Selected upstream Spark 4.1.3 assertions also pass with the native rewrite enabled.

The broader native run has a timing-sensitive failure in the unchanged S3 credential refresh test, which passes in isolation.

Draft pending broader Spark CI: please apply run-spark-4.1-tests and run-all-spark-profiles before marking ready for review.

@github-actions github-actions Bot added enhancement New feature or request area:scan Parquet scan / data reading area:expressions Expression evaluation labels Sep 30, 2026
@peterxcli peterxcli mentioned this pull request Oct 2, 2026
10 of 42 tasks
@peterxcli
peterxcli marked this pull request as ready for review October 4, 2026 14:03

@sunchao sunchao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

  • Prior state and problem: Spark’s whole-value Variant scan rewrite caused native scans to fall back, including under Spark 4.1’s default configuration.
  • Design approach: Recognize exactly one RequestedVariantField.fullVariant, carry its identity through protobuf and Arrow metadata, and reuse the existing Variant normalizer.
  • Correctness / compatibility analysis: Request metadata matches Spark sources across 4.0.0, 4.0.4, 4.1.0, 4.1.3 and 4.2.0. Null handling and Spark’s wrapper layout agree. Typed, nested and multi-field requests retain fallback. No introduced P1/P2 issues found within this review.
  • Key design decisions: The dedicated request flag keeps serialization narrow. The wrapper shares normalized buffers and validity data without another full-column copy. Existing FFI ownership and row-conversion paths remain applicable.
  • Implementation sketch: Scan admission validates the request, serde preserves its identity, the schema adapter normalizes and wraps the column, and JVM import restores metadata for Spark’s projection.
  • Behavioral changes worth calling out: Compared with branch-1.1, whole-value rewritten scans intentionally become native, and shredded objects containing empty keys gain a reconstruction fix. The existing normalizer’s cost now also applies to rewritten scans. No performance benchmark was run.
  • Suggested improvements: No P1/P2 code changes to request.

Reviewed all 18 changed files at e02715d6d868f4da4707f077bc048e2ad5dbbf66 against base fef94f6cd78b18151dff57b7a936798385356de5. GitHub confirms non-draft status. The snapshot and live discussion endpoints contain no existing review concerns. Routed skills: review-comet-pr, review-comet-expression-pr, and review-comet-ffi-pr.

Exact-head CI: run 37207859295 passed native tests, including all three new Rust regression tests, and Spark 4.1 scans, including the new whole-value and fallback assertions. Shuffle, TPC-H, native build and profile compilation checks also passed. Expressions, execution and TPC-DS remain running. No failed checks were reported.

Validation limits: Spark SQL jobs were skipped, and nondefault Spark profile runtime tests were not run. The local native attempt failed because HDFS compilation could not find jni.h. A subsequent build without HDFS reached its 180-second limit before executing tests. No local JVM tests completed. Broader compatibility validation remains outstanding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:expressions Expression evaluation area:scan Parquet scan / data reading enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Variant] Support Spark's pushed one-field VariantStruct (whole-value pushVariantIntoScan rewrite) in native Parquet scans

2 participants